package kr.hkit.androidcomplete01.ch08;

import kr.hkit.androidcomplete01.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

//392페이지 롱클릭
public class LongClickEx extends Activity {
	private int mCount = 0;
	private TextView mTextCount;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.ch08_longclickex);
		
		mTextCount = (TextView) findViewById(R.id.count);
		
		findViewById(R.id.decrease).setOnLongClickListener(mLongClickListener);
		findViewById(R.id.increase).setOnLongClickListener(mLongClickListener);
}
	
	public void mOnClick(View v) {
		switch (v.getId()) {
		case R.id.decrease :
			mCount--;
			mTextCount.setText("" + mCount);
			break;
		case R.id.increase:
			mCount++;
			mTextCount.setText("" + mCount);
			break;
		}
	}
	
	View.OnLongClickListener mLongClickListener = new View.OnLongClickListener() {
		
		@Override
		public boolean onLongClick(View v) {
			
			switch (v.getId()) {
				case R.id.decrease:
					mCount = 0;
					mTextCount.setText("" + mCount);
					return true;
				case R.id.increase:
					mCount = 100;
					mTextCount.setText("" + mCount);
					break;
			}
			return false;
		}
	};
}
